package com.yc.myspringboot.aop.demo3;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import com.yc.myspringboot.annotation.HfiTrace2;

@Component
@Aspect
public class TracingAspect {
    @Before("@annotation(test)")//和下面的参数列表对应
    public void beforeTest(JoinPoint point, HfiTrace2 test){
        System.out.println("method3 " + point.getSignature().getName() + " is called on " + point.getThis() + " with " +
                "args" + " " + point.getArgs());
        System.out.println("before invoke: "+ test.name());
    }
 
    @AfterReturning(value = "@annotation(test)", returning = "rvt")//和下面的参数列表对应
    public void afterTest(JoinPoint point, HfiTrace2 test, Object rvt) {
        System.out.println("method3 "+point.getSignature().getName() + " returns " + rvt);
        System.out.println("after invoke: " + test.name());
    }
}
